<?php
namespace Home\Controller;
use Think\Controller;
use Org\Util\Step;
class IndexController extends Controller {
    public function index(){
    	import("Org.Util.Step");
    	//所有分类列表    	
    	$all = M('step')->order('sort')->select();
    	//所有子分类
    	$small = M('step')->where(array('pid'=>array('neq',0)))->order('sort')->select();
   	   	$this->assign('small',$small);    	  
    	//排序后的所有分类列表
    	$step = Step::showfenlei($all);    	
    	$this->assign('step',$step);   
    	//主页显示博文
    	$boke = D('bokegl')->relation(true)->where(array('del' =>0))->limit(35)->order('time',DESC)->select();
    	$this->assign('boke',$boke); 	
    	//推荐博文
    	$recommend = D('bokegl')->relation(true)->where(array('del' =>0 , 'attr[id]' =>(array('IN',2))))->limit(10)->select();  
    	//print_r($recommend);die;
    	$this->assign('recommend',$recommend);    
       	//最新发布博文
    	$new = M('boke')->order('time desc')->where(array('del' =>0))->limit(8)->select();    	
    	$this->assign('new',$new);
    	$this->display();
    }
    public function serach(){
    	$name = $_POST['name'];
    	$where = (
    			array('name'=>$name)
    			);
    	$count = M('step')->where($where)->count();
    	if(!$count)
    	{$this->error("没有该列表！");}
    	else{
    		$arr = M('step')->where($where)->find();
    		$id = $arr['id'];  
    		$this->redirect('Home/List/index/btid/'.$id);    		
    	} 
    }
}